<?php

class User
{
    static $id;
    static $islogin = false;

    static function Init()
    {
        User::Login();
    }
    
    
    static function GenerateID()
    {
        return sha1(sha1("ka&*^&T".md5(time())).rand()."&^");
    }

    static function Login()
    {
        if(Context::$cookies["auth"]&&preg_match("/^[a-z0-9]{5,64}$/", Context::$cookies["auth"]))
        {
            User::$id = Context::$cookies["auth"];
            User::$islogin = true;
        }
        else
        {
            Context::$cookies["auth"] = User::GenerateID();
            User::$id = Context::$cookies["auth"];
            User::$islogin = true;
        }

    }

    static function Logout()
    {
        unset(Context::$cookies["auth"]);
        User::$islogin = false;
    }
};


?>